'use strict';

/* App Module */
var app = angular.module('mytree', ['ui','ngResource'], function($routeProvider,$locationProvider) {
    $routeProvider.
    when('/',{templateUrl:'partials/gf-cms.html',controller: GfCmsCtrl}).
    otherwise({redirectTo: '/'});
// $locationProvider.html5Mode(true);
});
app.value('ui.config',{
    jq:{
           //tree:{
           //         dataUrl:'category',
           //     },
           treeview:{
                      url: "category",
                      showcheck: true, 
                      animate:true,
                      onnodeclick:function(item){alert('test');},
                      //ajax:{
                      //    type: "GET",
                      //    //url:"category",    
                      //    success: function(x){
                      //       $.get("products/category.json",function(result){a=result;});
                      //    },
                      //}
                      //
                    },
           jqGrid:{
                      url:"product/search/",//"products/prod.json",
                      enableSearch:true,
                      datatype:"json",
                      autowidth:false,
                      viewrecords:true,
                      colNames:['PUBLISHED','HOT','ID','NAME','AGREEMENT','TITLE','CHANNEL','CODE','TYPE','DESC'],
                      colModel:[
                                {name:'published',index:'published',width:80},
                                {name:'hot',index:'hot',width:80},
                                {name:'id',index:'id',width:0,searchtype:"integer"},
                                {name:'name',index:'name',width:280},
                                {name:'agreement',index:'AGREEMENT',width:100},
                                {name:'title',index:'Name',width:60},
                                {name:'channel_desc',index:'channel',width:60},
                                {name:'code',index:'ModifiedDate',width:60},
                                {name:'product_type',index:'type',width:80},
                                {name:'description',index:'desc',width:0,hidden:true},
                                ],
                       jsonReader:{
                           root:"items",
                           page:"pageNum",
                           total:"pageCount",
                           records:"count",
                           repeatitems:false
                       },
                       rowNum:20,
                       rowList:[10,20,30],
                       pager:'#mypage',
                       sortname:'id',
                       sortorder:"desc",
                       caption:'products',
                       showQuery: true,
                       multiselect:true,
                       multipleSearch:true, multipleGroup:true,
                       onSelectRow:function(id){
                           var data=$('#mytable').jqGrid('getRowData',id); //alert(data['description']);
                           $('#details').html(data['description']);
                       },
                       height:'100%'
                  }
       }
});
